# -*- coding: utf-8 -*-
# @Time    : 2021/4/20 17:30
# @Author  : JoSuper
# @File    : main.py
# @Software: PyCharm
# @Date    : 2021/4/20
from access_course import ViewCourse
from config import Config
from doHomeWork import DoHomeWork

import argparse

parser = argparse.ArgumentParser('introduce how to use')
parser.add_argument('-v', "--view-course",
                    action="store_true",
                    required=False,
                    help='to view course video')
parser.add_argument('-home', "--homework",
                    action="store_true",
                    required=False,
                    help='do home work')
parser.add_argument('-u', "--user",
                    action="store",
                    required=True,
                    help='homework website username')
parser.add_argument('-p', "--password",
                    action="store",
                    required=True,
                    help='homework website password')
args = parser.parse_args()
print(args)


class Main(object):

    def __init__(self):
        self.config = Config

    def init(self):
        self.config.username = args.user
        self.config.password = args.password
        self.config.login()

    def run_view_courses(self):
        view_course = ViewCourse(self.config)
        view_course.run()

    def do_homework(self):
        homework = DoHomeWork()
        homework.run()

    def run(self):
        self.init()
        # 看视频
        if args.view_course:
            self.run_view_courses()
        # print("课程阅读执行完毕")
        # 做客观题作业
        if args.homework:
            self.do_homework()


if __name__ == '__main__':
    app = Main()
    # print("run")
    app.run()
